package zw_1001_1100.zw_1018_可被5整除的二进制前缀;

import java.util.ArrayList;
import java.util.List;

class Solution {

    public static void main(String[] args) {
        int[] nums = {0, 1, 1, 1, 1, 1};
        List<Boolean> list = prefixesDivBy5(nums);
        for (Boolean b : list) {
            System.out.print(b + " ");
        }
    }


    public static List<Boolean> prefixesDivBy5(int[] nums) {
        List<Boolean> answer = new ArrayList<Boolean>();
        int prefix = 0;
        int length = nums.length;
        for (int i = 0; i < length; i++) {
            prefix = ((prefix * 2) + nums[i]) % 5;
            answer.add(prefix == 0);
        }
        return answer;
    }
}
